﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using GWA.GriWebServ;

namespace GWA.Nurse
{
    public partial class Nurse : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                GetPatients();
            }  
        }

        private void GetPatients()
        {
            Service1 s1 = new Service1();
            Patient[] pat = s1.GetAllPatients();
            PatientGrid.DataSource = pat;
            PatientGrid.DataBind();
        }

        protected void EditPatient(Object src, GridViewCommandEventArgs e)
        {
            // get the row index stored in the CommandArgument property
            int index = Convert.ToInt32(e.CommandArgument);
            // get the GridViewRow where the command is raised
            GridViewRow selectedRow = ((GridView)e.CommandSource).Rows[index];

            
            Response.Redirect("~/Nurse/EditPatient.aspx?id=" + selectedRow.Cells[0].Text);
        }
    }
}
